package org.example.codeservce.controller;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

public class IPUtils {
    public static String getClientIpAddress(HttpServletRequest request) {
        // 获取所有请求头的名称
        Enumeration<String> headerNames = request.getHeaderNames();
        System.out.println(request.getHeader("user-agent"));
        // 遍历请求头名称，并逐个获取对应的值
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            String headerValue = request.getHeader(headerName);
            System.out.println(headerName + ": " + headerValue);
        }

        return "ipAddress";
    }
}
